const domainName = getApp().globalData.domainName
const parameter = getApp().globalData.parameter
const exam_items = [{id:1,name:'理论考试'},{id:2,name:'综合问答考试'},{id:3,name:'实践飞行考试'},{id:4,name:'地面站考试'},{id:5,name:'口试考试'},]
// pages/students/exam/set_examInfo/set_examInfo.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    exam_items,
  },

  show_pageContainer(e){
    this.setData({
      show:true,
      set_item:e.currentTarget.id
    })
  },
  
  cancel_set(){
    this.setData({
      theory_passed:'',comprehension_passed:'',fly_passed:'',gs_passed:'',oral_passed:''
    })
  },

  set_passed(e){
    this.data.set_value = e.detail.value
  },

  submit(){
    wx.showModal({
      content: '确定提交吗？',
      title: '提示',
      success: res => {
        if(res.confirm){
          wx.request({
            url: domainName + 'set_examInfo_submit',
            data: {
              jg_stu_id:this.data.stu_info.jg_stu_id,
              set_item:this.data.set_item,
              set_value:this.data.set_value,
            },...parameter,
            success: res => {
              if(res.data.update_res){
                wx.showToast({
                  title: '提交完成',
                })
                this.page_init(this.data.stu_info.jg_stu_id)
              }
            },
          })
        }
      },
    })
  },

  page_init(jg_stu_id){
    wx.request({
      url: domainName + 'set_examInfo_init',
      data: {jg_stu_id},...parameter,
      success: res => {
        this.setData({
          examInfo:res.data.examInfo,
          show:false,
        })
      },
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    let stu_info = JSON.parse(decodeURIComponent(options.stu_info))
    this.page_init(stu_info.jg_stu_id)
    this.setData({
      stu_info
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

})